
<template>
  <view class="page">
    <view class="center col ae">
      <Upload :file="user.avatar" tag="avatar" type="3" class="head-icon" />
      点击更换头像
    </view>
    <van-form>
      <van-form-item label="姓名">
        <input
          class="van-input-text"
          v-model="user.realname"
          placeholder="请输入姓名"
          type="text"
        />
      </van-form-item>
      <van-form-item label="性别">
        {{ user.gender ? "女" : "男" }} <van-switch v-model="user.gender" />
      </van-form-item>
      <van-cell
        title="出生年月"
        :desc="user.birthday"
        @click="show = true"
        is-link
      ></van-cell>
      <van-popup
        v-model="show"
        round
        position="bottom"
        :style="{ height: '30%' }"
      >
        <van-datetime-picker
          v-model="currentDate"
          type="date"
          title="选择年月日"
          :min-date="minDate"
          :max-date="maxDate"
        />
      </van-popup>
      <van-form-item label="所在地">
        <input
          class="van-input-text"
          v-model="user.address"
          placeholder="请输入所在地"
          type="text"
        />
      </van-form-item>
      <van-form-item label="公司名称">
        <input
          v-model="user.companyName"
          class="van-input-text"
          placeholder="请输入公司名称"
          type="text"
        />
      </van-form-item>
      <van-form-item label="公司地址">
        <input
          v-model="user.companyAddress"
          class="van-input-text"
          placeholder="请输入公司地址"
          type="text"
        />
      </van-form-item>
      <van-form-item label="手机号">
        <input
          v-model="user.mobile"
          class="van-input-text"
          placeholder="请输入手机号"
          @input="inputPhone"
        />
      </van-form-item>
      <van-form-item label="座右铭">
        <van-textarea
          v-model="user.motto"
          placeholder="请输入座右铭"
          type="text"
        />
      </van-form-item>
      <view class="ae2"></view>
      <van-form-item label="实名认证">
        <view class="flex">
          <Upload :file="user.autonymPath1" type="3" tag="autonymPath1" />
          <Upload
            :file="user.autonymPath2"
            type="3"
            tag="autonymPath2"
            style="margin-left: 20px"
          />
        </view>
      </van-form-item>
      <view class="ae2"></view>
      <van-form-item label="执业经纪认证">
        <view class="flex">
          <Upload :file="user.brokerPath" type="3" tag="brokerPath" />
        </view>
      </van-form-item>
      <view class="ae2"></view>
      <van-form-item label="公司认证">
        <view class="flex">
          <Upload :file="user.companyPath" type="3" tag="companyPath" />
        </view>
      </van-form-item>

      <view class="tip-infos"> 备注:以上认证将在提交后24小时内审核完成。 </view>

      <view class="center">
        <van-button
          class="submit btn"
          color="#FBD100"
          type="primary"
          @click="submit"
          >完成提交</van-button
        >
      </view>
    </van-form>

    <view class="center bg"> <view class="appPng"> </view> </view>
  </view>
</template>
<script>
import Upload from "@/commpent/uploader.vue";
export default {
  components: { Upload },
  data() {
    return {
      user: {},
      currentDate: new Date(),
      minDate: new Date(1950, 1, 1),
      maxDate: new Date(),
      show: false,
    };
  },
  created() {
    this.loadUser();
  },
  mounted() {},
  methods: {
    loadUser() {
      console.log("获取用户信息");
      var tmp = this.$store.state.apiUserInfo;
      console.log(tmp);
      this.user = tmp.data.data;
      this.user.autonymPath1 = this.user.autonymPath.split(",")[0];
      this.user.autonymPath2 = this.user.autonymPath.split(",")[1];
      this.user.birthday = this.user.birthday.split(" ")[0];
    },
    confirm(data) {
      this.user.birthday = data;
      this.show = false;
    },
    inputPhone(e) {
      console.log(e.target.value);
    },
    submit() {
      var th = this;
      console.log("获取照片信息");
      var tmp = this.$store.state.tmp;
      console.log(tmp);
      var { autonymPath1, autonymPath2 } = tmp;
      var autonymPath1 = autonymPath1 + "," + autonymPath2;
      console.log(this.user);
      this.user.gender = this.user.gender ? 1 : 0; // 1 女性
      this.ajax
        .post(
          this.ajax.api.updateUser,
          Object.assign(this.user, {
            autonymPath1,
            nikename: this.user.realname,
            status: 0,
            // autonymPath:this.data.idFileList1[0].url + ',' + this.data.idFileList1[0].url,
            // brokerPath:this.data.codeFileList1[0].url,
            // companyPath:this.data.companyFileList[0].url,
          })
        )
        .then((res) => {
          console.log(res); // 提示成功后返回页面
          th.setData({});
        });
    },
  },
};
</script>  

<style>
.flex-content {
  display: flex;
  justify-content: center;
}
.app-container {
  height: 100vh;
  overflow: auto;
  padding-top: 50px;
  font-size: 14px;
}
.up-item {
  margin: 0 10px;
}

.tip-infos {
  padding: 30px;
  color: #ccc;
  font-size: 12px;
}
.submit {
  border-radius: 50px;
  margin: 20px 0 20px 0;
  padding: 0 50px;
  font-size: 20px;
}
.bg {
  background: #ccc;
  padding: 10px;
}
.ae {
  color: #aeaeae;
  font-weight: 400;
  padding-bottom: 10px;
  border-bottom: 10px solid #eee;
}
.ae2 {
  width: 100%;
  height: 2px;
  padding-bottom: 10px;
  border-bottom: 10px solid #eee;
}
.head-icon {
  border: 2px solid #fbd100;
  border-radius: 50%;
  overflow: hidden;
  margin-bottom: 10px;
}
.van-cell__value {
  width: 65% !important;
  text-align: left !important;
}
</style>
 